package com.st.sbmb.controller.mbcontroller;

import com.st.sbmb.mapper.UserMapper;
import com.st.sbmb.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/sb")
public class MybatisController {
    @Autowired
    private UserMapper userMapper;
    @GetMapping("getone")
    public String getOne(){
        int id = 2;
        User user = userMapper.findUserById(id);
        System.out.println(user);
        return "获取到一个用户:" + user;

    }

    @GetMapping("getall")
    public String getAll(){
        List userAll = userMapper.findAllUser();
        System.out.println(userAll);
        return "获取到一个用户:" + userAll;

    }


}
